<template>
	<view>
		<view @click="buttonClick()" class="button flex-column-center">
			下单
		</view>
	</view>
</template>

<script>
	import {
		mapActions,
		mapState
	} from "vuex";
	import {
		t_order,
	} from '@/api/index.js'
	export default {
		components: {},
		computed: {

		},
		data() {
			return {
				userinfo:{},
				shop:{},
				id:0,
				item:{}
			}
		},
		computed: {
			...mapState([
				'baseColor'
			]),
		},
		onPageScroll(e) {
			if (e.scrollTop > 20) {
				this.backgroundColor = "#AED0FC"
			} else {
				this.backgroundColor = "#ffffff00"
			}
		},
		onShow() {
	
		},
		onLoad(e) {
			this.item=uni.getStorageSync('product')
			this.shop=uni.getStorageSync('shop')
			this.userinfo=uni.getStorageSync('userinfo')
			
			// this.id=e.id
			// this.loadData()
		},
		//下拉刷新
		onPullDownRefresh() {


		},
		//加载更多
		onReachBottom() {

		},
		onPageScroll(e) {
			// if (e.scrollTop > 20) {
			// 	this.backgroundColor = "#FBF9FF"
			// } else {
			// 	this.backgroundColor = "#ffffff00"
			// }
		},
		methods: {
			buttonClick(){
				this.t_order()
			},
			t_order () {
				var data={
					productId:this.item.id,
					shopId:this.item.shopId,
					shopName:this.shop.shopName,
					customerId:this.userinfo.userId,
					customerName:this.userinfo.userName,
					serviceId:this.item.serviceId,
					serviceName:this.item.serviceName,
				}
				t_order(data).then(res => {
					this.showToast('下单成功')
					setTimeout(() => {
						uni.switchTab({
							url:'/pages/work/work'
						})
					}, 1500)
				})
			},
			
		
		}
	}
</script>

<style lang="scss">
	

.button{
	margin: 30rpx;
	height: 95rpx;
	background: #ED6F1A;
	border-radius: 5rpx;
	font-weight: 400;
	font-size: 32rpx;
	color: #FFFFFF;
}

</style>